//
//  UIBarButtonItem.swift
//  01-sinaWeibo-05-09
//
//  Created by mac on 16/5/20.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit
//扩展
extension UIBarButtonItem {
    
    convenience init(imageName:String,target: AnyObject?,action: Selector
        ) {
            let button = UIButton()
            button.setImage(UIImage(named:imageName), forState: UIControlState.Normal)
            button.setImage(UIImage(named:imageName + "_highlighted"), forState: UIControlState.Highlighted)
            button.sizeToFit()
            //点击事件
            button.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
            
            // 创建UIBarButtonItem, 需要调用自己的指定构造函数
            self.init(customView: button)
            
            
    }
    
    
}